package com.hopu.pyq.service.impl;

import com.hopu.pyq.dao.UserDAO;
import com.hopu.pyq.entity.User;
import com.hopu.pyq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDAO userDAO;

    @Override
    public User login(String username, String password) {
        User user = userDAO.selectUserByUsername(username);
        if(user != null){
            if(password.equals(user.getPassword())){
                return user;
            }
        }
        return null;
    }

    @Override
    public List<User> findUsersByPyqId(Integer pyqId) {
        return userDAO.selectUsersByPyqId(pyqId);
    }
}
